package com.jxb.netty.rocketmqNetty;

import com.jxb.netty.rocketmqNetty.serializable.SerializeType;

import static com.jxb.netty.rocketmqNetty.serializable.RemotingCommand.SERIALIZE_TYPE_ENV;
import static com.jxb.netty.rocketmqNetty.serializable.RemotingCommand.SERIALIZE_TYPE_PROPERTY;

public class Test {
    public static void main(String[] args) {
//        byte[] bytes = markProtocolType(21, SerializeType.ROCKETMQ);
//        System.out.println(getHeaderLength(21));
        System.out.println("===============>" + System.getenv(SERIALIZE_TYPE_ENV));
        String protocol = System.getProperty(SERIALIZE_TYPE_PROPERTY, System.getenv(SERIALIZE_TYPE_ENV));
        System.out.println("protocol=================>"+protocol);
    }
    private static int getHeaderLength(int length) {
        return length & 0xFFFFFF;
    }
    public static byte[] markProtocolType(int source, SerializeType type) {
        byte[] result = new byte[4];

        result[0] = type.getCode();
        result[1] = (byte) ((source >> 16) & 0xFF);
        result[2] = (byte) ((source >> 8) & 0xFF);
        result[3] = (byte) (source & 0xFF);
        return result;
    }
}
